package com.xunge.mapper;

import com.xunge.pojo.Attendance;
import com.xunge.pojo.AttendanceQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AttendanceMapper {

    /**
     * 分页查询考勤信息
     */
    List<Attendance> list(AttendanceQueryParam attendanceQueryParam);

    /**
     * 新增考勤记录
     */
    @Insert("insert into attendance(student_id, clazz_id, course_id, attendance_date, status, remark, create_time, update_time) " +
            "values(#{studentId}, #{clazzId}, #{courseId}, #{attendanceDate}, #{status}, #{remark}, now(), now())")
    void insert(Attendance attendance);

    /**
     * 根据ID查询考勤记录
     */
    @Select("select * from attendance where id = #{id}")
    Attendance getById(Integer id);

    /**
     * 根据ID修改考勤记录
     */
    void update(Attendance attendance);

    /**
     * 根据ID删除考勤记录
     */
    @Delete("delete from attendance where id = #{id}")
    void deleteById(Integer id);

    /**
     * 批量删除考勤记录
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 根据学生ID查询考勤记录
     */
    @Select("select * from attendance where student_id = #{studentId}")
    List<Attendance> getByStudentId(Integer studentId);

    /**
     * 根据课程ID查询考勤记录
     */
    @Select("select * from attendance where course_id = #{courseId}")
    List<Attendance> getByCourseId(Integer courseId);

    /**
     * 根据班级ID查询考勤记录
     */
    @Select("select * from attendance where clazz_id = #{clazzId}")
    List<Attendance> getByClazzId(Integer clazzId);
} 